package cz.czu.pef.DataModelling.domainObjects;

import java.util.*;

public class Person extends IdObjectImpl implements IdObject
{
  private static final long serialVersionUID = 3114451056057208926L;

  /*
	 * Entity attributes
	 */
	private String firstName;
	private String lastName;
	private Date birthDate;
	private Address address;

	/*
	 * Relations
	 */
	private Set<MedicalExamination> medicalExaminations;
	private Set<Training> trainings;
	private Set<Machinery> machineries;
	private Set<Employee> employees;

	public Person()
	{
		super();
	}

	public Person(final String fn, final String ln)
	{
		super();
		setFirstName(fn);
		setLastName(ln);
	}

	public Person(final String fn, final String ln, Address address)
	{
		setFirstName(fn);
		setLastName(ln);
		setAddress(address);
	}

	public Address getAddress()
	{
		return address;
	}

	public String getFirstName()
	{
		return firstName;
	}

	public String getLastName()
	{
		return lastName;
	}

	public void setAddress(Address address)
	{
		this.address = address;
	}

	public void setFirstName(final String firstName)
	{
		this.firstName = firstName;
	}

	public void setLastName(final String lastName)
	{
		this.lastName = lastName;
	}

	public Date getBirthDate()
	{
		return birthDate;
	}

	public void setBirthDate(Date birthDate)
	{
		this.birthDate = birthDate;
	}

	public Set<Employee> getEmployees()
	{
		return employees;
	}

	public List<Employee> getEmployeesAsList()
	{
		return new ArrayList<Employee>(getEmployees());
	}

	public void setEmployees(Set<Employee> employees)
	{
		this.employees = employees;
	}

	public Set<Machinery> getMachineries()
	{
		return machineries;
	}

	public List<Machinery> getMachineriesAsList()
	{
		return new ArrayList<Machinery>(getMachineries());
	}

	public Set<MedicalExamination> getMedicalExaminations()
	{
		return medicalExaminations;
	}

	public List<MedicalExamination> getMedicalExaminationsAsList()
	{
		return new ArrayList<MedicalExamination>(getMedicalExaminations());
	}

	public void addMedicalExamination(MedicalExamination medicalExamination)
	{
		if (medicalExaminations == null)
			medicalExaminations = new HashSet<MedicalExamination>();
		medicalExaminations.add(medicalExamination);
	}

	public Set<Training> getTrainings()
	{
		return trainings;
	}

	public List<Training> getTrainingsAsList()
	{
		return new ArrayList<Training>(getTrainings());
	}

	public void addTraining(Training training)
	{
		if (trainings == null)
			trainings = new HashSet<Training>();

		trainings.add(training);
	}

	
  public void setMedicalExaminations(Set<MedicalExamination> medicalExaminations)
  {
    this.medicalExaminations = medicalExaminations;
  }

  
  public void setTrainings(Set<Training> trainings)
  {
    this.trainings = trainings;
  }

  
  public void setMachineries(Set<Machinery> machineries)
  {
    this.machineries = machineries;
  }

  public String toString()
	{
		StringBuilder builder = new StringBuilder();
		builder.append("Person [getFirstName()=");
		builder.append(getFirstName());
		builder.append(", getLastName()=");
		builder.append(getLastName());
		builder.append(", getBirthDate()=");
		builder.append(getBirthDate());
		builder.append(", getAddress()=");
		builder.append(getAddress());
		builder.append(", getMedicalExaminations()=");
		builder.append(getMedicalExaminations());
		builder.append(", getTrainings()=");
		builder.append(getTrainings());
		builder.append("]");
		return builder.toString();
	}

}